﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace Hwh_VoteSys.Models.Database
{
    public partial class Hwh_VoteSysContext : DbContext
    {
        public Hwh_VoteSysContext()
        {
        }

        public Hwh_VoteSysContext(DbContextOptions<Hwh_VoteSysContext> options)
            : base(options)
        {
        }

        public virtual DbSet<CompanyAwardSituation> CompanyAwardSituations { get; set; }
        public virtual DbSet<CompanyDataUpload> CompanyDataUploads { get; set; }
        public virtual DbSet<User> Users { get; set; }
        public virtual DbSet<Vote> Votes { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=Hwh_VoteSys;Integrated Security=SSPI");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<CompanyAwardSituation>(entity =>
            {
                entity.HasKey(e => e.ComAtId)
                    .HasName("PK__Company___6E9229745BD8C8CC");

                entity.ToTable("Company_Award_Situation");

                entity.Property(e => e.ComAtId).HasColumnName("Com_AT_id");

                entity.Property(e => e.AwardType).HasColumnName("Award_Type");

                entity.Property(e => e.ComAwardTime)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasColumnName("Com_AwardTime");

                entity.Property(e => e.ComId).HasColumnName("Com_ID");

                entity.Property(e => e.ProjectPic1).HasColumnName("Project_pic1");

                entity.Property(e => e.ProjectPic2).HasColumnName("Project_pic2");

                entity.Property(e => e.ProjectPic3).HasColumnName("Project_pic3");

                entity.Property(e => e.ProjectPic4).HasColumnName("Project_pic4");

                entity.Property(e => e.ProjectPic5).HasColumnName("Project_pic5");
            });

            modelBuilder.Entity<CompanyDataUpload>(entity =>
            {
                entity.HasKey(e => e.ComId)
                    .HasName("PK__Company___D85628ACAD73E3C6");

                entity.ToTable("Company_Data_Upload");

                entity.Property(e => e.ComId).HasColumnName("Com_ID");

                entity.Property(e => e.ComIntroduction)
                    .IsRequired()
                    .HasMaxLength(255)
                    .HasColumnName("Com_Introduction");

                entity.Property(e => e.ComLogo)
                    .IsRequired()
                    .HasColumnName("Com_Logo");

                entity.Property(e => e.ComName)
                    .IsRequired()
                    .HasMaxLength(30)
                    .HasColumnName("Com_Name");

                entity.Property(e => e.ComProjectType)
                    .IsRequired()
                    .HasMaxLength(10)
                    .HasColumnName("Com_Project_Type");

                entity.Property(e => e.ReviewStatus).HasColumnName("Review_Status");

                entity.Property(e => e.UEmail)
                    .IsRequired()
                    .HasMaxLength(30)
                    .IsUnicode(false)
                    .HasColumnName("U_Email");

                entity.Property(e => e.VNum).HasColumnName("V_Num");
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.HasKey(e => e.UId)
                    .HasName("PK__Users__5A2040DB2B665F10");

                entity.Property(e => e.UId).HasColumnName("U_ID");

                entity.Property(e => e.CreateTime).HasColumnType("datetime");

                entity.Property(e => e.Password)
                    .IsRequired()
                    .HasMaxLength(32)
                    .IsUnicode(false);

                entity.Property(e => e.Salt)
                    .IsRequired()
                    .HasMaxLength(6)
                    .HasColumnName("salt")
                    .IsFixedLength(true);

                entity.Property(e => e.UEmail)
                    .IsRequired()
                    .HasMaxLength(30)
                    .IsUnicode(false)
                    .HasColumnName("U_Email");

                entity.Property(e => e.UName)
                    .IsRequired()
                    .HasMaxLength(30)
                    .HasColumnName("U_Name");

                entity.Property(e => e.UserType)
                    .IsRequired()
                    .HasMaxLength(10)
                    .HasColumnName("User_type");
            });

            modelBuilder.Entity<Vote>(entity =>
            {
                entity.HasKey(e => e.VId)
                    .HasName("PK__Vote__B35D778C867AF847");

                entity.ToTable("Vote");

                entity.Property(e => e.VId).HasColumnName("V_Id");

                entity.Property(e => e.ComId).HasColumnName("Com_ID");

                entity.Property(e => e.CreateTime).HasColumnType("date");

                entity.Property(e => e.UId).HasColumnName("U_ID");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
